package com.zidian.study.utils;

import com.orhanobut.hawk.Hawk;
import com.zidian.study.Application.MyApplication;

/**
 * Created by GongCheng on 2016/10/17 0017.
 */

public class SharedPreferenceUtils {
    private final static String CURRENT_TIME_MILLIONS = "currentTimeMillions";
    private final static String CURRENT_WEEK = "currentWeek";

    /**
     * 初始化
     */
    public static void init() {
        Hawk.init(MyApplication.getInstance()).build();
    }

    /**
     * 存储timeMillions
     *
     * @param timeMillions
     */
    public static void setDate(long timeMillions) {
        Hawk.put(CURRENT_TIME_MILLIONS, timeMillions);
    }

    /**
     * 读取timeMillions
     *
     * @return
     */
    public static long getDate() {
        if (Hawk.get(CURRENT_TIME_MILLIONS) == null) {
            return 0;
        }
        return Hawk.get(CURRENT_TIME_MILLIONS);
    }

    /**
     * 储存周次
     *
     * @param currentWeek
     */
    public static void setCurrentWeek(int currentWeek) {
        Hawk.put(CURRENT_WEEK, currentWeek);
    }

    public static int getCurrentWeek() {
        if (Hawk.get(CURRENT_WEEK) == null) {
            return 0;
        }
        return Hawk.get(CURRENT_WEEK);
    }

    public static void clear() {
        Hawk.deleteAll();
    }
}
